<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
    <link rel="stylesheet" href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css">
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
    <script src="../script/api.js"></script>
    <style>
		body {
			font-family: Arial;
		}
		/* 输入框下面的列表标题行（未完成的检测单信息）样式 */
		p.cimc-grid-label {
			border-left: 0.25 rem solid rgba(22, 155, 213, 1);
			padding-left: 0.3 rem;
		}
		span.cimc-grid-label {
			color: #000;
			font-size: 16px;
		}
		ul.aui-list:before {
			height: 0px !important;
		}/**** 去掉条目的细线 ****/
		div.cimc-list-header {
			height: 1.8 rem !important;
			min-height: 0px !important;
		}
		/**** 每条条目的高度 ****/
		li.aui-list-item {
			min-height: 0px !important;
		}/* 去掉最小高度限制 */
		div.cimc-list-item-inner {
			min-height: 0px !important;/* 去掉最小高度限制 */
			padding-top: 0.2 rem;
			padding-right: 0.1 rem !important;
			height: 32px;
		}
		/* 去掉每一行自带的间隔线 */
		div.cimc-list-item-inner:after {
			height: 0px !important;
			background-color: #000000 !important;
		}
		/* 设置标签体字体大小 */
		div.cimc-list-item-inner-lable {
			text-align: left;
			padding-top: 0rem !important;
			padding-bottom: 0rem !important;
			text-align: left;
			font-size: 13px;
			/*width:50%;*/
		}
		.table {
			margin-bottom: 15px;
			width: 100%;
			border-collapse: collapse;
			font-size: 13px;
			border-spacing: 0;
		}
		.table td {
			height: 35px;
			text-align: center;
			border: 1px solid #CBD6DE;
			font-size: 12px;
			padding: 0;
			margin: 0;
			vertical-align: middle !important;
		}
		.weui-form-preview {
			position: static;
			margin-bottom: 56rpx;
			background-color: transparent;
			padding-top: 10rpx;
		}
		.weui-form-preview:before {
			border-top: none;
			border-bottom: none;
		}
		.weui-form-preview:after {
			border-top: none;
			border-bottom: none;
		}
		.weui-form-preview__hd {
			position: static;
		}
		.font-color {
			color: #6b717d;
		}
		.view-title {
			float: left;
			text-align: justify;
			text-align-last: justify;
			font-weight: bold;
		}
		.view-title-height {
			line-height: 16px;
			font-weight: normal;
			font-size: 15px;
		}
		.view-content-height {
			line-height: 15px;
			font-weight: normal;
			padding-top: 5px;
		}
		.view-bottom {
			padding-bottom: 10rpx;
		}
		.view-left {
			float: left;
			font-weight: normal;
		}
		.view-justify {
			text-align: justify;
			text-align-last: justify;
		}
		.normal {
			font-weight: normal
		}
		.weui-form-preview__hd:after {
			content: " ";
			position: absolute;
			left: 0;
			bottom: 0;
			right: 0;
			height: 1px;
			border-bottom: none;
			left: 15px;
			right: 15px;
		}
		.weui-form-preview__hd::before {
			border-bottom: none;
		}
		.card {
			border: 2px solid #ffffff;
			border-radius: 6px;
			background-color: #ffffff;
			margin: 6px;
			margin-top: -5px;
			height:100px;
		}
		.inline {
			display: inline
		}
		.title_bold {
			font-weight: bold
		}
		.title_normal {
			font-weight: normal
		}
		.weui-form-preview__item {
			overflow: hidden
		}

		.state {
			overFlow-x: scroll;
			overFlow-y: hidden;
			white-space: nowrap;
		}
		.layui-form-label {
				float: left;
				display: block;
				width: 80px;
				font-weight: 400;
				line-height: 20px;
				text-align: right;
		}

		/* 未选 */
		.input_check{
				display: inline-block;
				border: 1px solid #ccc;
				border-radius: 4px;
				width: 20px;
				height: 20px;
		}

		.layui-input-block {
			min-height: 36px;
			margin-left: 0;
		}
		.table thead {
							width: calc( 100% - 1em)
					}

					.table thead,
					 tbody tr {
							 display: table;
							width: 100%;
							 table-layout: fixed;
					}

					.table tbody {
							 display: block;
							 height: 181px;
							 overflow-y: scroll;
					 }

					.btn_color {
			background-color:#33ffcc;
			color:white;
			 }

		.aui-grid .aui-grid-label {
			display: block;
				font-size: 0.7rem;
				position: relative;
				margin-top: 0.1rem;
		}

		.layui-input, .layui-textarea {
				display: block;
				width: 100%;
				padding-left: 5px;
		}
    </style>
</head>

<body>
    <header id='header' class="aui-bar aui-bar-nav" style="background-color: #03a9f4">
        <a class="aui-pull-left aui-btn" onclick="api.closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="middle">
            工序报工
        </div>
        <a class="aui-pull-right aui-btn" onclick="queryWorkTaskOrder()">
			        <span style="padding-right:5px;"class="aui-iconfont aui-icon-recovery"></span>
			</a>
    </header>
		<div class="aui-content">
			<div class="aui-form" style="margin-top:15px;">
				<div class="aui-content aui-margin-b-15">
					<ul class="aui-list aui-form-list" style="font-size: 14px;">
						<li class="aui-list-item">
							<div class="aui-list-item-inner">
								<div class="aui-list-item-label1" style="margin-top:5px;font-size: 14px;">
									<img src="../image/scanner.png" />
								</div>
								<input type="text" class="aui-input"  placeholder="请输入工序编码" style="width: 80%;font-size: 16px;" id="workCellCode" />
								<i class="aui-input-addon aui-iconfont aui-icon-scan " style="padding-right:10px;font-size: 1.6rem" onclick="doScan('workCellCode');"></i>
							</div>
						</li>
						<li class="aui-list-item">
							<div class="aui-list-item-inner">
								<div class="aui-list-item-label1" style="margin-top:5px;font-size: 14px;">
									<img src="../image/scanner.png" />
								</div>
								<input type="text" class="aui-input"  placeholder="请输入工单号"
								style="width: 80%;font-size: 16px;" id="workOrderCode" />
								<i class="aui-input-addon aui-iconfont aui-icon-scan " style="padding-right:10px;font-size: 1.6rem" onclick="doScan('workOrderCode');"></i>
							</div>
						</li>
					</ul>
				</div>
			</div>
		</div>
		<!-- <div class="weui-form-preview" id="workCellReportOpUl">
			<div  class="weui-form-preview__hd card" style="height:60px;padding-top:5px">
				<div class="weui-form-preview__item view-content-height font-color" style="font-size:15px">
					<div style="width: 180px;float: left;margin-left:10px ;padding-top: 0.4rem !important;" >
 		  				<label class="layui-form-label" style="width:90px;" >派工属性</label>
					       <div class="layui-input-block">
					           <select onchange="queryWorkTaskOrder()" id="dispatchType" class="layui-input layui-unselect" style="margin-left:-30px;width:50px;border-radius: 4px;min-height: 20px;padding-left: 5px;">
					               <option  value='0' >工位</option>
					               <option  value='1' >工序</option>
					           </select>
					       </div>
					</div>
					<div  onclick= "changeIsPublish()" class='aui-grid-label cimc-list-item-inner-lable' style = 'float:left;margin-top: 10px;display:inline;font-size:15px;margin-left: 15px;'>
							<input type="checkbox"  name="isPublish" value="isPublish" checked="checked" class="input_check" />
					</div>
					<label onclick="changeIsPublish()" style="margin-left:5px;margin-top: 13px;height:20px;display:inline-block;color:#4169E1" >已发布</label>
				</div>
			</div>
		</div> -->
		<div class="weui-form-preview" id="workCellReportOpUl" style="padding-top:10px;">
			<div  class="weui-form-preview__hd card" style="padding-top: 10px;">
				<div id="op" class='aui-grid-label cimc-list-item-inner-lable state' style='height:30px;display:inline;font-size:15px;width: 47%;float: left;' >
					工序:
				</div>
				<div></div>
        <div id="mrl" class='aui-grid-label cimc-list-item-inner-lable state' style='margin-left:5px;height:30px;display:inline;font-size:15px;width: 50%;float: left;' >
					工位:
				</div>
				<!-- <div id="workCell" class='aui-grid-label cimc-list-item-inner-lable state' style='margin-left:5px;height:30px;display:inline;font-size:15px;width: 50%;float: left;' >
					工位:
				</div> -->
				<div></div>
				<!-- <div id="mrl" class='aui-grid-label cimc-list-item-inner-lable state' style = 'height:30px;display:inline;font-size:15px;width: 100%;float: left;' >
				          产品:
				</div> -->
				<div></div>
				<!-- <div id="remark" class='aui-grid-label cimc-list-item-inner-lable state' style = 'height:30px;display:inline;font-size:15px;width: 100%;float: left;' >
				           备注:
				</div> -->
			</div>
		</div>
		<div style="clear:both"></div>
		<div class="table-responsive" id="appStorage" style="overflow-y:auto">
			<table id="tab" class="table table-bordered " style="margin-top:5px;table-layout: fixed;">
				<thead>
					<tr id="tr1" style="text-align: center;background-color: #DCE9F2;color: #467aa7;font-family: 微软雅黑;font-size: 13px;font-weight: bold;">
						<th id="allboxs" style="width:30px"></th>
						<td style="width:30px" >顺序</td>
						<td style="display: none">id</td>
						<td style="width:65px" >工单号</td>
						<td style="width:45px" >状态</td>
						<td style="width:45px" >计划数</td>
						<td style="width:45px" >报工数</td>
						<!-- <td id="workCellTd" >工位</td> -->
					</tr>
				</thead>
				<tbody id="J_TbData">

        </tbody>
			</table>
		</div>

		<div id="noFull_ref" class="aui-content-padded" style="display: flex;margin-top:-1px">
			<p>
				<div id="full" class="aui-btn aui-btn-block btn_color" onclick="goFeedPage()" >
					上料
				</div>
			</p>
		</div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script>
    var trackOrderList;
    apiready = function() {
      $("#workCellCode").focus();
      idSelector = "workCellCode";
      // doSearch(start);
    }
		//扫描
	  function doScan(str) {
	 		 var moduleScanner = api.require('moduleScanner');
	 		 var params = {
	 				 top: 150, //扫描窗口的上边距
	 				 width: 250, //扫描窗口的宽
	 				 height: 250, //扫描窗口的高
	 				 useColor: false, //是否使用自己设定的颜色(startColor和endColor),
	 				 //如果不使用设定的颜色就使用默认的那张网格图
	 				 startColor: '#0F08C8FF', //渐变起始颜色
	 				 endColor: '#7F08C8FF', //渐变结束颜色
	 				 animTime: 2200, //扫描动画时间,单位为毫秒
	 		 };
	 		 moduleScanner.toScannerActivityForResult(params, function(ret, err) {
				 var SMequipCode = ret;
				//工位
				if (str == 'workCellCode') {
					var text = document.getElementById("workCellCode");
					text.value = SMequipCode;
					$("#workCellCode").val(text.value);
					queryWorkTaskOrder();
				}
        //工单
				if (str == 'workOrderCode') {
					var text = document.getElementById("workOrderCode");
					text.value = SMequipCode;
					$("#workOrderCode").val(text.value);
					queryWorkTaskOrder();
				}
	 		 });
	  }
    $('#workCellCode').bind('keypress',function(event){
          if(event.keyCode == 13)
          {
            if($("#workCellCode").val()!=null&&$("#workCellCode").val()!=""){
              queryWorkTaskOrder();
            }
          }
      });

      $('#workOrderCode').bind('keypress',function(event){
          if(event.keyCode == 13)
          {
            if(($("#workCellCode").val()!=null&&$("#workCellCode").val()!="")&&($("#workOrderCode").val()!=null&&$("#workOrderCode").val()!="")){
              queryWorkTaskOrder();
            }
          }
      });
		function queryWorkTaskOrder() {
			api.showProgress({
			    title: '数据加载中...',
			    text: '请稍等...',
			    duration:15000,
			});

			var workCellCode = $("#workCellCode").val();
			var workOrderCode = $("#workOrderCode").val();
			if (workCellCode==null||workCellCode=="") {
				alertInfo("请扫描工序编码");
				api.hideProgress();
				return;
			}
      var un = localStorage.getItem('un');
			var serverUrl = localStorage.getItem('serverUrl');
			var url = serverUrl + "/app/paVtrackRecordList";
			var params = new Object();
			params.url = url;
			params.method = 'post';
			params.dataType = 'json';
			var data = {
				values : {
					un:un,
					opCode : workCellCode,
					workOrderCode : workOrderCode
				}
			};
			api.ajax({
					url: url,
					method: 'post',
					dataType: 'json',
					timeout: 300,
					returnAll: false,
					data: data
			}, function(ret, err) {
					if (ret) {
							var data = JSON.stringify(ret);
							var myobj = eval("(" + data + ")");
							//返回成功
							if (myobj.code == "0") {
									trackOrderList = eval(myobj.list);
									var html = "";
									var seq = 1;
									for (var i = 0; i < trackOrderList.length; i++) {
										// var isUrgency = trackOrderList[i].isUrgency; // 紧急标识
										var state = '';
										if (trackOrderList[i].disCodeState == 0) {
											state = '未开工';
										} else if (trackOrderList[i].disCodeState == 1) {
											state = '开工';
										} else if (trackOrderList[i].disCodeState == 2) {
											state = '暂停';
										}

										var orderSeq = trackOrderList[i].seq == 0 ? '' : trackOrderList[i].seq;

										html += "<tr>";
										html += "<td id='"+ seq +"' style='width:30px' onclick='showRemark("+ seq +")'><input name='boxs' type='checkbox' value='"+ seq +"'></td>"
										html += "<td style='width:30px'>" + orderSeq + "</td>"
										html += "<td style='display:none'>" + trackOrderList[i].sysid + "</td>"
										html += "<td onclick='gotoPage(\"" + (i) + "\")' style='width:65px;word-wrap: break-word'><font style='border-bottom: 1px solid #9cd9f5' >" + trackOrderList[i].workOrderId + "</font></td>"

										html += "<td style='width:45px'>" + state + "</td>"
										html += "<td style='width:45px'>" + trackOrderList[i].planQty + "</td>"
										html += "<td style='width:45px'>" + trackOrderList[i].effectiveQty + "</td>"
										// 生产类型:工位
										// if(workCellCode!=trackOrderList[i].workCellCode) {
										// 	html += "<td style='word-wrap: break-word' class='state'><font color='green' style='text-align: right;'>" + trackOrderList[i].workCellGid + "</font></td>"
										// } else {
										// 	html += "<td style='word-wrap: break-word' class='state' style='text-align: right;'>" + trackOrderList[i].workCellGid + "</td>"
										// }

										html += "</tr>";
										seq++;
									}
									$("#J_TbData").html(html);
									console.log("1234html",html);
									passWorkCellCode = workCellCode;
									api.hideProgress();
									//失败
							} else if (myobj.code == "1") {
									//清空表格数据
									$api.html($api.byId("tbodyHtml"), "");
									api.toast({
											msg: myobj.message,
											duration: 3000
									});
							}
					}
			});
		}

    function showRemark(seq) {
      var namebox = $("input[name^='boxs']");  //获取name值为boxs的所有input
            for(i = 0; i < namebox.length; i++) {
                namebox[i].checked=false;    //js操作选中checkbox
                if(i == seq-1) {
                  namebox[i].checked=true;
                }
            }
            console.log("seq",seq);
            console.log("ttrtr",trackOrderList);
            var op = trackOrderList[seq-1].opName;
            // var remark = trackOrderList[seq-1].remark;
            var mrl =  "[" + trackOrderList[seq-1].mrlCode + "]" + " " + trackOrderList[seq-1].produName;
            // var workCellName = trackOrderList[seq-1].workCellGid;
            $("#op").html("工序:" + op);
            // $("#workCell").html("工位:" + workCellName);
            $("#mrl").html("产品:" + mrl);
            // $("#remark").html("备注:" + remark);
    }
    //去上料界面
    function goFeedPage()
		{
		    var J_TbData = document.getElementById('J_TbData');    // table 的 id
			var rows = J_TbData.rows;

			var checks= new Array();
			$('input[name="boxs"]:checked').each(function(){
				checks.push($(this).val());
			});
			if(checks.length!=1) {
        api.toast({
            msg: "请选择一条派工数据进行上料!",
            duration: 3000
        });
        return;
			}
      console.log("checks[0]",checks[0]);
			var trackOrder = trackOrderList[checks[0]-1];
			var values = {
				mrl : "[" + trackOrder.mrlCode + "]" + " " + trackOrder.produName,
			}

      var trackOrderId = trackOrder.sysid;

			values["trackOrder"] = JSON.stringify(trackOrder);
			values["currentWorkCellCode"] = $("#workCellCode").val();
			api.openFrame({
				name : 'fullBox-choose-op',
				url : 'fullBox-choose-op.html',
				pageParam : values,
				bounces : false,
			});
		}
    //点击工单号
    function gotoPage(i) {
			var url = '';
			var title = '';
			var trackOrder = trackOrderList[i];
			var un = localStorage.getItem('un');
				var serverUrl = localStorage.getItem('serverUrl');
				var url = serverUrl + "padController!vaildLinkPLCRecod.m";
				var params = new Object();
				params.url = url;
				params.method = 'post';
				params.dataType = 'json';

				var workCellCode = $("#workCellCode").val();

						var values = {
              name: api.winName,
							trackId : trackOrder.sysid,
							opId : trackOrder.opId,
							workOrderCode : trackOrder.workOrderId,
							dispatchCode : trackOrder.dispatchCode,
							disCodeState : trackOrder.disCodeState,
              opCode : trackOrder.opCode,
							opName : trackOrder.opName,
							workCellName : trackOrder.workCellName,
							workCellCode : trackOrder.workCellCode,
							mrl : "[" + trackOrder.mrlCode + "]" + " " + trackOrder.produName,
							mrlCode : trackOrder.mrlCode,
							mrlName : trackOrder.produName,
							planQty : trackOrder.planQty,
							effectiveQty : trackOrder.effectiveQty,
							uneffectiveQty : trackOrder.uneffectiveQty,
							discardQty : trackOrder.discardQty,
							realTimeDaqQty : trackOrder.realTimeDaqQty,
							lastOpId : trackOrder.lastOpId,
							lastOpCode : trackOrder.lastOpCode,
							lastOpName : trackOrder.lastOpName,
							workCells : trackOrder.workCells, //  上一道工序的工位集合
							actualBeginDate : trackOrder.actualBeginDate, // 开工时间
							realTimeHuCode : trackOrder.realTimeHuCode, // 实时HU编号
							historyDaqQty : trackOrder.historyDaqQty, // 历史采集数量
							wsFirstChkFlag : trackOrder.wsFirstChkFlag, // 班次检验任务生成标识
							isUseHu : trackOrder.isUseHu,
							isWipFeed : trackOrder.isWipFeed,
							isFeedLotCode : trackOrder.isFeedLotCode,
							isLinkProdu : trackOrder.isLinkProdu,
							isNoFullUseHu : trackOrder.isNoFullUseHu,
							lastWorkCellCode : trackOrder.lastWorkCellCode,
							nextWorkCellCode : trackOrder.nextWorkCellCode,
							lastEffectiveQty : trackOrder.lastEffectiveQty,
							passWorkCellCode : passWorkCellCode,
							un : un
						}
						values["memoryBoxCode"] = trackOrder.memoryBoxCode;
						values["memoryBoxQty"] = trackOrder.memoryBoxQty;
						url = 'operation-report_operate.html';
						title = '工序报工';
						values["url"] = url;
						values["title"] = title;
						//标题来自动态传递
						api.openWin({
							name : 'operation-report_operate',
							url : 'operation-report_operate.html',
							pageParam : values,
							bounces : false,
						});

		}
    //返回按钮
    function closeWin() {
        api.closeWin({});
    }
</script>

</html>
